package com.yuanian.wf.listener;

import com.yuanian.wf.event.Event;
import com.yuanian.wf.exception.WfException;
import com.yuanian.wf.pojo.model.ProcessManager;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;

public abstract class Listener<E extends ApplicationEvent> implements ApplicationListener<E> {

    /**
     * 调用onApplicationEvent方法
     * @param processkey
     * @param taskKey
     * @param event
     */
    protected void activeApplicationEvent(String processkey, String taskKey, Event event) {

        try {
            //获取listener对象对应的方法
            ProcessManager.invoke(processkey, taskKey, event);
        } catch (Exception e) {
            e.printStackTrace();
            throw new WfException(e.getMessage());
        }

    }

}

